package cn.wj.school.cloud.utils;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

public class DateUtils {

    public static LocalDate date2LocalDate(Date date) {
        if (date == null) {
            return LocalDate.now();
        }
        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()).toLocalDate();
    }

    public static void main(String[] args) {
        Date date = new Date();
        Long second =  Duration.between(date.toInstant(),
                org.apache.commons.lang.time.DateUtils.addSeconds(date, 120).toInstant()).toMinutes();
        System.out.println(second);
    }
}
